# Copyright (c) 2017 ~ 2025, the original author wangl.sir individual Inc,
# All rights reserved. Contact us wanglsir<wangl@gmail.com, 983708408@qq.com>
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# For more setup recommendations or green installation guidelines:
# see: http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
# ----- Basic. -----
#
server_id = SERVER_ID
#basedir = /usr/lib/mysql-current
#datadir = {basedir}/data
#socket = {basedir}/run/mysqld-{MYSQL_USER}.sock
#pid-file = {basedir}/run/mysqld-{MYSQL_USER}.pid
#log-error = {basedir}/log/mysqld-{MYSQL_USER}.err

# If you do not specify the binding ipv4 address, the ipv6 address will be used first,
# which may cause the initialization of the MySQL Group Replication cluster to fail. refer to:
# https://github.com/mysql/mysql-server/blob/mysql-5.7.30/sql/conn_handler/socket_connection.cc#L387
bind-address = 0.0.0.0
port = 3306

#
# ----- SQL. -----
#
# Ignore SQL condition case.(1:ignore)
# Note: When mysql8+, after initialization, is is not allowed to change this setting.
# see: http://blog.itpub.net/20893244/viewspace-2565069/
# see: https://bugs.mysql.com/bug.php?id=90695
lower_case_table_names = 1
sql_mode = NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
explicit_defaults_for_timestamp = true
# Disabling symbolic-links is recommended to prevent assorted security risks     
symbolic-links = 0

#
# ----- Performance. -----
#
# Set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
#innodb_buffer_pool_size = 1G
#innodb_buffer_pool_instances = 8
#innodb_buffer_pool_chunk_size = 128M
max_allowed_packet = 1G
max_connections = 2000
# Notice: unsigned value 2147483648 adjusted to 1073741824.
slave_max_allowed_packet = 1G

# To SET options mainly useful for reporting servers. The server defaults are faster for
# transactions and fast SELECTs. adjust sizes as needed, experiment to find the optimal values.
#join_buffer_size = 128M
#sort_buffer_size = 2M
#read_rnd_buffer_size = 2M

#
# ----- Binlog. -----
#
binlog_format = ROW
binlog_checksum = NONE
log_bin=binlog
log_slave_updates = ON
relay_log_info_repository = TABLE
# Notice: Unsigned value 2147483648 adjusted to 1073741824, max allowed set to 1G ?
max_binlog_size = 1G
expire_logs_days = 15

#
# --- Group replication. ---
#
# see: https://dev.mysql.com/doc/refman/5.7/en/group-replication-options.html
gtid_mode = ON
enforce_gtid_consistency = ON
master_info_repository = TABLE

transaction_write_set_extraction = XXHASH64
# see: https://github.com/mysql/mysql-server/blob/mysql-5.7.30/rapid/plugin/group_replication/src/plugin.cc#L1726
# see: SELECT * FROM performance_schema.global_variables WHERE VARIABLE_NAME='group_replication_group_name'
loose-group_replication_group_name = "5db40c3c-180c-11e9-afbf-005056ac6820"
loose-group_replication_start_on_boot = OFF
# It's not allowed to use Double quotation marks(") and (=) No spaces after, refer to: https://bugs.mysql.com/bug.php?id=98524
loose-group_replication_local_address='HOST:23366'
loose-group_replication_group_seeds='SEEDS'
loose-group_replication_ssl_mode = DISABLED
loose-group_replication_bootstrap_group = OFF
loose-group_replication_recovery_user = repl
loose-group_replication_ip_whitelist = '192.168.0.0/16,172.0.0.0/8,10.0.0.0/8,127.0.0.1'

# Single primary mode.
loose-group_replication_single_primary_mode = ON
loose-group_replication_enforce_update_everywhere_checks = OFF
# Multi primary mode.
#loose-group_replication_single_primary_mode = OFF
#loose-group_replication_enforce_update_everywhere_checks = ON